package com.ruoyi.yljf.service.impl;

import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.yljf.mapper.BaseQuestionBankMapper;
import com.ruoyi.yljf.domain.BaseQuestionBank;
import com.ruoyi.yljf.service.IBaseQuestionBankService;

import javax.annotation.Resource;

/**
 * 基础题库Service业务层处理
 * 
 * @author metaee
 * @date 2025-04-24
 */
@Service
public class BaseQuestionBankServiceImpl extends ServiceImpl<BaseQuestionBankMapper, BaseQuestionBank> implements IBaseQuestionBankService {
    @Resource
    private BaseQuestionBankMapper baseQuestionBankMapper;
    
    /**
     * 查询基础题库列表
     * 
     * @param baseQuestionBank 基础题库
     * @return 基础题库
     */
    @Override
    public List<BaseQuestionBank> selectBaseQuestionBankList(BaseQuestionBank baseQuestionBank) {
    	LambdaQueryWrapper<BaseQuestionBank> queryWrapper = Wrappers.lambdaQuery();
        if (StringUtils.isNotEmpty(baseQuestionBank.getQuestionTitle())) {
			queryWrapper.eq(BaseQuestionBank::getQuestionTitle, baseQuestionBank.getQuestionTitle());
		}
        if (StringUtils.isNotEmpty(baseQuestionBank.getQuestionOptions())) {
			queryWrapper.eq(BaseQuestionBank::getQuestionOptions, baseQuestionBank.getQuestionOptions());
		}
        if (StringUtils.isNotEmpty(baseQuestionBank.getCorrectAnswer())) {
			queryWrapper.eq(BaseQuestionBank::getCorrectAnswer, baseQuestionBank.getCorrectAnswer());
		}
        if (StringUtils.isNotEmpty(baseQuestionBank.getErrorAnswer())) {
			queryWrapper.eq(BaseQuestionBank::getErrorAnswer, baseQuestionBank.getErrorAnswer());
		}
        if (StringUtils.isNotEmpty(baseQuestionBank.getAc())) {
			queryWrapper.eq(BaseQuestionBank::getAc, baseQuestionBank.getAc());
		}
        if (StringUtils.isNotEmpty(baseQuestionBank.getQuestionText())) {
			queryWrapper.eq(BaseQuestionBank::getQuestionText, baseQuestionBank.getQuestionText());
		}
        if (StringUtils.isNotEmpty(baseQuestionBank.getQuestionType())) {
			queryWrapper.eq(BaseQuestionBank::getQuestionType, baseQuestionBank.getQuestionType());
		}
        return baseQuestionBankMapper.selectList(queryWrapper);
    }

	@Override
	public BaseQuestionBank selectByid(Long id) {
		return baseQuestionBankMapper.selectById(id);
	}
}
